/*
 * This class is a POJO and is used for parsing the query
 * It represents the position of each keyword in the current query under consideration
 */
package com.querie.parser;

/**
 *
 * @author a-skoshy
 */
public class QueryKeyword implements Comparable<QueryKeyword>{

    private String keyword;
    private String actualWord;
    private int startChar;
    private int endChar;

    public QueryKeyword(String keyword, String actualWord, int startChar, int endChar) {
        this.keyword = keyword;
        this.actualWord = actualWord;
        this.startChar = startChar;
        this.endChar = endChar;
    }

    public int compareTo(QueryKeyword obj) throws ClassCastException {
        int otherStartChar = ((QueryKeyword) obj).getStartChar();

        if (this.startChar < otherStartChar) {
            return -1;

        } else if (this.startChar > otherStartChar) {
            return 1;
        } else {
            return 0;
        }
    }

    public int getStartChar() {
        return startChar;
    }

    public int getEndChar() {
        return endChar;
    }

    public String getKeyword() {
        return keyword;
    }

    public String toString() {
        return "Keyword:" + keyword + " Actual Word:" + actualWord + " Start:" + startChar + " End:" + endChar + "\n";
    }
}
